RAIS  3.2
C:/Projekte/RAIS/Specific Masks/AccountRequest.aspx.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Data;
00030 using System.Configuration;
00031 using System.Collections;
00032 using System.Web;
00033 using System.Web.Security;
00034 using System.Web.UI;
00035 using System.Web.UI.WebControls;
00036 using System.Web.UI.WebControls.WebParts;
00037 using System.Web.UI.HtmlControls;
00038 
00039 using RAIS.Common.UserManagement;
00040 
00041 using FunctionRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole>;
00042 
00043 namespace RAIS.UI.SpecificMasks
00044 {
00048     public partial class AccountRequest : System.Web.UI.Page
00049     {
00050         #region Event handlers 
00051 
00052         protected void Page_PreLoad(object sender, EventArgs e)
00053         {
00054             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00055         }
00056 
00064         protected void Page_Load(object sender, EventArgs e)
00065         {
00066                         this.Response.Cache.SetNoStore();
00067                         if (Request["Action"] != null && Request["Action"] == "ReturnLoginPage")
00068                 this.Session[UI.Common.Constants.CURRENT_USER_TAG] = null;
00069                         if (!this.IsPostBack)
00070                         {
00071                                 UI.Common.UserManagement.InitializeUserTypesList(this.DDLaccounttype);
00072                                 //UI.Common.UserManagement.InitializePredefinedFunctionalRolesList(this.DDLaccounttype);
00073 
00074                                 UI.Common.Localisation.TranslatePage(this);
00075                                 this.SetFocus(this.TXTfullname);
00076                         }
00077                 }
00088         protected void BTNsubmitrequest_Click(object sender, EventArgs e)
00089         {
00090             string actionMessage = string.Empty;
00091                         bool addRequest = false;
00092                         bool success = false;
00093 
00094                         UserData userData = this.GetUserDataFromMask();
00095 
00096                         if (ApplicationLogicLayer.UserManagement.UserExists(userData.Login, ref actionMessage))
00097                         {
00098                                 // Unlock if user locked
00099                                 UserData user = ApplicationLogicLayer.UserManagement.GetUserData(userData.Login);
00100                                 if (user.Locked)
00101                                         addRequest = true;
00102                         }
00103                         else
00104                                 addRequest = true;
00105 
00106                         if (addRequest)
00107                         {
00108                                 success = ApplicationLogicLayer.UserManagement.AddAccountRequest(userData, ref actionMessage);
00109                         }
00110 
00111                         if (success)
00112                         {
00113                                 this.LBLresult.ForeColor = System.Drawing.Color.Green;
00114                                 this.BTNsubmitrequest.Enabled = false;
00115                         }
00116                         else
00117                         {
00118                                 this.LBLresult.ForeColor = System.Drawing.Color.Red;
00119                         }
00120                         this.LBLresult.Text = actionMessage;
00121                 }
00122         #endregion
00123                 //*********************************************************************
00124                 #region Private helper methods
00125 
00131                 bool ValidateData(ref string returnMessage)
00132                 {
00133                         if (ApplicationLogicLayer.UserManagement.UserExists(this.TXTusername.Text, ref returnMessage))
00134                                 return false;
00135                         else
00136                                 return true;
00137                 }
00142                 protected UserData GetUserDataFromMask()
00143                 {
00144                         UserData userData = new UserData();
00145 
00146                         userData.TypeText = this.DDLaccounttype.SelectedValue;
00147                         //userData.FunctionalRole = this.SelectedFunctionRole;
00148                         userData.Login = this.TXTusername.Text;
00149                         userData.Password = this.TXTpassword.Text;
00150 
00151                         userData.CompleteName = this.TXTfullname.Text;
00152                         userData.Email = this.TXTemail.Text;
00153                         userData.AddressLine1 = this.TXTaddress1.Text;
00154                         userData.AddressLine2 = this.TXTaddress2.Text;
00155                         userData.AddressLine3 = this.TXTaddress3.Text;
00156                         userData.City = this.TXTcity.Text;
00157                         userData.PostCode = this.TXTpostcode.Text;
00158                         userData.AccountRequestComment = this.TXTcomments.Text;
00159 
00160                         userData.Status = UserData.UserStatus.NotActive;
00161 
00162                         return userData;
00163                 }
00164                 #endregion
00165                 //*********************************************************************
00166                 #region Properties
00167 
00170                 private FunctionRole SelectedFunctionRole
00171                 {
00172                         get
00173                         {
00174                                 FunctionRoles functionRoles = (FunctionRoles)this.Session[RAIS.UI.Common.Constants.PREDEFINED_FUNCTION_ROLES_TAG];
00175                                 if (functionRoles != null && functionRoles.ContainsKey(this.DDLaccounttype.SelectedValue))
00176                                         return functionRoles[this.DDLaccounttype.SelectedValue];
00177                                 else
00178                                         return null;
00179                         }
00180                 }
00181                 #endregion
00182     }
00183 }